package com.mo.util;

import com.mo.channel.MyChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
@EnableBinding(MyChannel.class)
public class MessageSend {
    @Autowired
    @Qualifier("myoutput")
    private MessageChannel output;

    /**
     * 发送消息
     * @param obj
     */
    public void send(Object obj){
        output.send(MessageBuilder.withPayload(obj).build());
    }

}
